import pygame, pygame.gfxdraw, random
from pygame.locals import *
from qnd import *
FRAMERATE = 30

BLACK = (0,0,0)
WHITE = (255,255,255)

class Particle:
	"""
	Stores a particle's position and velocity.
	"""
	def __init__(self, x, y, vx, vy):
		"""Initialize the particle"""
		self.x = x
		self.y = y
		self.vx = vx
		self.vy = vy

	def draw(self, screen):
		"""Draws the particle on the given screen"""
		# self.x and self.y are floats, meaning that they have
		# fractional parts (3.9, 4.5, .8), unlike integers, which
		# are just whole numbers (3, 2, 1).

		# int(a) removes the fractional part from a floating-point
		# number, giving you an integer.
		pygame.gfxdraw.pixel(screen, int(self.x), int(self.y), BLACK)

	def update(self):
		"""Updates the particle's position."""
		self.x += self.vx
		self.y += self.vy

screen = pygame.display.set_mode((500,400))
input = InputHandler()
clock = pygame.time.Clock()

p = Particle(10, 10, 1, 1)

particle_list = []

# Add 200 particles to our list (range gives us a list of the numbers
# 0 to 199, which is 20 numbers).
for i in range(200):
	# random.uniform(a, b) gives you a random number between a and b.
	# We'll start our particles at the point (250, 200), which is at
	# the center of our screen.
	particle_list.append(Particle(250, 200,
		random.uniform(-5, 5), random.uniform(-5, 5)))

# Game loop
while True:
	input.update()
	screen.fill(WHITE)
	for p in particle_list:
		p.update()
		p.draw(screen)
	pygame.display.flip()
	clock.tick(FRAMERATE)